
<% provide(:title, @user.nickname) %>
<h1>
	<%= gravatar_for @user %>
	<%= @user.nickname %>
</h1>

<%if @user.id==1 %>
	<h4>
	  Welcome, Administrator
	</h4>

	<table style="width:100%">
	  <thead>
	    <tr>
				<th>商品名称</th>
				<th>价格</th>
				<th>数量</th>
				<th>备注</th>
	      <th colspan="3">operate</th>
	    </tr>
	  </thead>

	  <tbody>
	    <% @products.each do |product| %>
	      <tr>
	        <td><%= product.name %></td>
					<td><%= product.price %></td>
					<td><%= product.amount %></td>
	        <td><%= product.remark %></td>
	        <td><%= link_to '查看', product %></td>
	        <td><%= link_to '编辑', edit_product_path(product) %></td>
	        <td><%= link_to '删除', product, method: :delete, data: { confirm: '确认删除?' } %></td>
	      </tr>
	    <% end %>
	  </tbody>
	</table>
	<%= link_to '新建商品', new_product_path %>
<% else %>
	<h4>
	  你可以开始购物了！
	</h4>

	<table style="width:100%">
	  <thead>
	    <tr>
				<th>商品名称</th>
				<th>价格</th>
				<th>数量</th>
				<th>备注</th>
	      <th colspan="3">operate</th>
	    </tr>
	  </thead>

	  <tbody>
	    <% @products.each do |product| %>
	      <tr>
	        <td><%= product.name %></td>
					<td><%= product.price %></td>
					<td><%= product.amount %></td>
	        <td><%= product.remark %></td>
	        <td><%= link_to '查看', product %></td>
					<td><%= button_to "加入购物车","/users/#{product.id}", remote: true %></td>
	      </tr>
	    <% end %>
	  </tbody>
	</table>
<% end %>